<?php
header('Content-type: application/json;charset=utf-8');
require_once(dirname(__FILE__) . '/../../inc/config.inc.php');
require_once(dirname(__FILE__) . '/../../function.php');
IsModelPriv('goodsorder');
$tbname = '#@__user';
//引入操作类
$field = isset($_POST['field']) ? $_POST['field'] : [];
$level = isset($field['level']) ? intval($field['level']) : 6;
$truename = empty($field['truename']) ? "" : htmlspecialchars($field['truename']);
$mobile = empty($field['mobile']) ? "" : htmlspecialchars($field['mobile']);
$school = empty($field['school']) ? "" : htmlspecialchars($field['school']);
$address = empty($field['address']) ? "" : htmlspecialchars($field['address']);
$id = empty($field['id']) ? 0 : intval($field['id']);
$action = empty($_POST['action']) ? "" : htmlspecialchars($_POST['action']);



//审核状态
if (!isset($field['ispm'])) {
    $ispm = 0;
} else {
    $ispm = 1;
}
if (!isset($field['isadmin'])) {
    $isadmin = 0;
} else {
    $isadmin = 1;
}
if (!isset($field['qiang'])) {
    $qiang = 0;
} else {
    $qiang = 1;
}

if (!isset($field['isreport'])) {
    $isreport = 0;
} else {
    $isreport = 1;
}

$time=time();

if ($action == 'update') {
    if($mobile=="" ||$level==0 || $truename=="" || $id==0 ){
        $row_arr['code'] = -1;
        $row_arr['msg'] = "参数错误";
        echo json_encode($row_arr);
        exit;

    }
    $dosql->ExecNoneQuery("UPDATE $tbname SET `level`='$level',school='$school',truename='$truename',mobile='$mobile',`address`='$address',updatetime='$time',`ispm`='$ispm',isadmin='$isadmin',qiang='$qiang',isreport='$isreport'  WHERE id=$id");

    $jssdk->return_json_body(['code'=>0,'msg'=>'编辑成功']);
}
